Skip to content

feat: add automatic low-power preference - #2995

Merged
steipete merged 4 commits into
steipete:mainfrom
elijahfriedman:feat/auto-enable-low-power
Aug 17, 2026
Merged

feat: add automatic low-power preference#2995
steipete merged 4 commits into
steipete:mainfrom
elijahfriedman:feat/auto-enable-low-power

Conversation

@elijahfriedman

@elijahfriedman elijahfriedman commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace the plain "Low Power Mode" toggle in Settings → General → Refreshing with a three-way Off / On / Automatic dropdown (same SettingsMenuPicker component used by Refresh Interval)
  • add LowPowerModePreference enum; Automatic resolves against the live system Low Power Mode state (ProcessInfo.processInfo.isLowPowerModeEnabled)
  • backgroundWorkLowPowerModeEnabled (read by every throttling call site: adaptive refresh, fixed-timer refresh, storage refresh, reset-boundary catch-up, Codex cost catch-up, iCloud sync gating) becomes a computed property derived from the new preference, so none of those call sites needed to change
  • migrate the legacy on/off UserDefaults bool to the new preference on first load, preserving existing users' behavior exactly (trueon, false/missing → off)
  • observe NSProcessInfoPowerStateDidChange in SettingsStore and bump backgroundWorkSettingsRevision whenever the preference is .automatic, so a running fixed-frequency refresh timer reclamps/unclamps immediately when the user toggles system Low Power Mode mid-session instead of waiting for an unrelated settings change to restart it
  • update the zh-Hans translation for the row's subtitle to match the new copy; every other locale already fell back to English for this subtitle and still does, unchanged — the Off/On/Automatic option labels reuse existing keys already translated in all 23 locales

Tests

  • add background low power mode migrates legacy enabled flag to on preference to SettingsStoreCoverageTests — verifies the legacy bool key migrates correctly and the new preference key persists
  • update background low power mode defaults off persists and drives effective web saver to exercise the new backgroundWorkLowPowerModePreference property
  • update 5 existing tests (AdaptiveRefreshHeuristicsTests, AdaptiveRefreshTimerTests, CodexBackgroundRefreshCoalescingTests, ProviderStorageFootprintTests) that force-enabled the old bool to set .backgroundWorkLowPowerModePreference = .on instead
  • focused swift test suite for the touched files green; two AdaptiveRefreshTimerTests timer-timeout failures are pre-existing flakes unrelated to this change (confirmed identical failures on unmodified base branch)
  • fix ProviderArchitectureGatekeeperTests allowlist: the new LowPowerModePreference code shifted the factory/minimax/zai construct in SettingsStore.swift from line 1073 to 1126; updated the pinned line number (anchor/fingerprint unchanged) to unblock the swift-test-macos CI shard

Verification

  • swift build clean
  • make check clean (0 lint violations, 0 format changes)
  • addressed 2 code-review findings: a test asserting the wrong default-persistence expectation, and the automatic-mode timer-restart gap described above

Screenshots

Screenshot 2026-08-16 at 9 53 53 PM

@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 90dcf06342

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread Sources/CodexBar/SettingsStore+Defaults.swift
Comment thread Tests/CodexBarTests/SettingsStoreCoverageTests.swift Outdated
@clawsweeper clawsweeper Bot added P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 7:36 AM ET / 11:36 UTC.

ClawSweeper review

What this changes

This PR replaces the background-refresh low-power toggle with Off, On, and Automatic choices that can follow macOS Low Power Mode.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for a maintainer product-direction decision on adding a persistent Automatic low-power choice; no concrete patch defect was found. Likely related people: Carl (original low-power feature) and Peter Steinberger (recent default-branch owner).

Priority: P3
Reviewed head: 46c56eafbb010f7666758831e20924bf44c27773
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The implementation and compatibility migration are coherent, with direct UI proof; the remaining gate is product acceptance rather than patch quality.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): The attached Settings screenshot directly demonstrates the after-fix three-choice picker, and the PR is labeled proof sufficient.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): The attached Settings screenshot directly demonstrates the after-fix three-choice picker, and the PR is labeled proof sufficient.
Evidence reviewed 6 items Current-main behavior: Current main exposes only a writable boolean preference and the Settings UI renders it as a toggle, so it does not already provide an Automatic choice.
Compatibility migration: The PR persists a three-state preference and maps legacy enabled values to on while defaulting missing or false legacy values to off.
Live power-state handling: The PR observes macOS power-state changes and bumps the existing background-work revision only while Automatic is selected, which causes fixed timers to restart with the newly effective interval.
Findings None None.
Security None None.

How this fits together

CodexBar’s Settings Store reads a persisted preference and exposes an effective low-power boolean to background refresh work. That value controls refresh scheduling, storage scans, and related battery-saving behavior.

flowchart LR
    A[Settings picker] --> B[Stored low-power preference]
    C[macOS Low Power Mode] --> D[Effective low-power decision]
    B --> D
    D --> E[Background refresh timer]
    D --> F[Storage and provider refreshes]
    E --> G[Usage updates]
Loading

Decision needed

Question Recommendation
Should CodexBar support a persistent Automatic low-power preference that follows macOS Low Power Mode for background refresh throttling? Approve Automatic mode: Accept the new three-choice preference and its migration as the supported background-refresh power policy.

Why: The implementation is coherent and preserves existing stored values, but whether this new user-facing mode belongs in the supported settings surface is a maintainer product choice.

Before merge

  • Resolve merge risk (P1) - Automatic changes the control from a fixed user choice to one that follows an external macOS state, so the permanent preference surface needs explicit product approval.
  • Complete next step (P2) - A human must decide whether Automatic belongs in the persistent preference surface; no narrow mechanical repair remains.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test delta production +88/-19; tests +26/-12 The new persisted setting, UI, and timer observation are accompanied by migration and existing refresh-test updates.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    If the product direction is approved, land the three-state preference with its compatibility migration and power-state timer restart; otherwise retain the existing explicit toggle.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

If the product direction is approved, land the three-state preference with its compatibility migration and power-state timer restart; otherwise retain the existing explicit toggle.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR adds a settings capability rather than reporting broken existing behavior; its attached screenshot directly shows the new picker.

Is this the best way to solve the issue?

Yes, conditionally: a three-state persisted preference with a narrow legacy migration is a maintainable implementation, but accepting the new mode requires product approval.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7c64d280f34f.

Labels

Label justifications:

  • P3: This is a low-risk optional settings capability awaiting product approval rather than an urgent regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): The attached Settings screenshot directly demonstrates the after-fix three-choice picker, and the PR is labeled proof sufficient.
  • proof: sufficient: Contributor real behavior proof is sufficient. The attached Settings screenshot directly demonstrates the after-fix three-choice picker, and the PR is labeled proof sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The attached Settings screenshot directly demonstrates the after-fix three-choice picker, and the PR is labeled proof sufficient.

Evidence

What I checked:

Likely related people:

  • Carl: Authored the merged commit that introduced CodexBar’s global low-power feature. (role: introduced existing behavior; confidence: high; commits: aeab80e099a3; files: Sources/CodexBar/SettingsStore+Defaults.swift, Sources/CodexBar/PreferencesGeneralPane.swift)
  • Peter Steinberger: Authored the PR base merge and current default-branch release commit, making him the strongest available owner for the product-scope decision. (role: recent default-branch contributor; confidence: medium; commits: 45ca0b4ef8c1, 7c64d280f34f; files: Sources/CodexBar/SettingsStore.swift, Sources/CodexBar/PreferencesGeneralPane.swift)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Obtain maintainer confirmation that Automatic should be a supported persistent preference.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-17T02:12:29.441Z sha 3a8ed65 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 2b1c559 into steipete:main Aug 17, 2026
9 checks passed
@elijahfriedman
elijahfriedman deleted the feat/auto-enable-low-power branch August 17, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants